<?php session_start();?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<script LANGUAGE="javascript">
function redirectPageComplete()
{	
	alert("บันทึกตัวอย่างสีและเนื้อผ้าสำเร็จ");
	location = "../../clothes.php";
}

function redirectPageIncomplete()
{
	alert("เกิดข้อผิดพลาดในการเพิ่มข้อมูล");
	location = "../../clothes.php";
}

function redirectPageIsnull()
{
	alert("ข้อมูลบางส่วนยังเป็น่ค่าว่าง กรุณาลงใหม่อีกครั้ง");
	location = "../../clothes.php";
	
}
<?php
include '../../../inc/reuse/dbconfig.php';

$id = $_POST['clothes_id'];
$description = $_POST['clothes_description'];
$modifier = $_SESSION['uid'];
$modified_datetime = date("YmdHis"); //เน€เธ�เน�เธ�เธงเธฑเธ�เน€เธ”เธทเธญเธ�เธ�เธตเน�เธฅเธฐเน€เธงเธฅเธฒเธ”เน�เธงเธข function date
if(isset($description) && $id != ""){
	$sql = "UPDATE clothes
			SET clothes_description = '$description',			
			modified_master_id = '$modifier',
			modified_date_time = '$modified_datetime' 
			WHERE clothes_id= $id";
	if(mysql_query($sql)){
		echo "redirectPageComplete();";
	}else{
		echo "redirectPageIncomplete();";
	}
}
else
{
	$sql = "INSERT INTO clothes (clothes_id,clothes_description,inserted_master_id,inserted_date_time,modified_master_id,modified_date_time)
	VALUES (null,'$description', '$modifier','$modified_datetime', '$modifier', '$modified_datetime')";
	if(mysql_query($sql)){
		echo "redirectPageComplete();";
	}else{
		echo "redirectPageIncomplete();";
	}	
}
mysql_close();
?>
</script>
</body>
</html>
